#include "StdAfx.h"
#include "GameBase.h"
#include "SubStructure.h"
#include "UserBullet.h"

UserBullet::UserBullet()
{
}

UserBullet::~UserBullet()
{
}

void UserBullet::SetMoveInfo(Move_info info)
{
	nowMove = info;
}

void UserBullet::SetDamage(DWORD nD)
{
	damage = nD;
}

DWORD UserBullet::GetDamage(){ return damage; }

void UserBullet::Init()
{
	nowMoveState1 = 0;
	nowMoveState2 = 0;
	moveCount = 0;
	aniCount = 0;
	thisliveCount = 0;
	thislimitTime = 0;
	SetGhostAni(*_pAni[0][0]);
}

void UserBullet::Draw()
{
	D3DXMATRIX matrix;
	D3DXMatrixIdentity(&matrix);
	
	D3DXMatrixTransformation2D(&matrix, 0, 0, 0, 0, 0, &pos);
	
	GameBase::pSprite->SetTransform(&matrix);

	GameBase::pSprite->Draw(nowAni.Texture,
				&nowAni.Source,
				NULL,
				NULL,
				nowAni.invisible );
	
	D3DXMatrixIdentity(&matrix);
	
	D3DXMatrixTransformation2D(&matrix, 0, 0, 0, 0, 0, &basepos);
	
	GameBase::pSprite->SetTransform(&matrix);

	GameBase::pSprite->Draw(GhostAni.Texture,
				&GhostAni.Source,
				NULL,
				NULL,
				GhostAni.invisible );
	
	D3DXMatrixIdentity(&matrix);
	GameBase::pSprite->SetTransform(&matrix);
}

void UserBullet::Move()
{
	midpos = pos;
	basepos = midpos;
	pos += nowMove.Move_Vel;
}

DWORD UserBullet::deleteCheck()
{
	if(pos.y < -90.0 || pos.x < -60.0 || pos.x > 480.0)
	{
		return OVERRANGEDELETE;
	}
	else
		return 0;
}

void UserBullet::SetGhostAni(Ani_info nAni)
{
	GhostAni = nAni;
	GhostAni.invisible = 0x80ffffff;
}